from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
import time
testCase="DBshop019_添加属性"
group="好好学习"
groupType="下拉"
groupName="天天向上"
num="255"
# 1.点击“添加属性”按钮，编写属性分组“好好学习”，属性类型“下拉”，属性名称“天天向上”，排序“255”。
firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
time.sleep(1)
DBshopEnterMenu3(firefox,"商品管理","商品属性","属性")
firefox.find_element_by_partial_link_text("添加属性").click()
# 属性分组“好好学习”
firefox.find_element_by_xpath(
    "//select[@id='attribute_group_id']/option[text()='%s']"%group).click()
time.sleep(1)
# 属性类型“下拉”
firefox.find_element_by_xpath(
    "//select[@id='attribute_type']/option[@value='select']").click()
time.sleep(1)
# 属性名称“天天向上”
firefox.find_element_by_id("attribute_name").send_keys(groupName)
time.sleep(1)
# 排序“255”
firefox.find_element_by_id("attribute_sort").clear()
time.sleep(1)
firefox.find_element_by_id("attribute_sort").send_keys(num)
time.sleep(1)
# 2.点击“保存属性信息”按钮，保存成功。
firefox.find_element_by_xpath("//button").click()
time.sleep(2)
if firefox.find_element_by_xpath("//td[text()='%s']"%groupName).is_displayed():
    writeLog("%s 测试通过" % testCase)
else:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()
